import Vue from 'vue'
import { mapState, mapActions } from 'vuex'
Vue.mixin({
	data() {
		return {
			query: {},
			modalName: null,
			List: [],
			page:0,
			finish: false,
			UID:'geyi',
		}
	},
	computed: {
		...mapState(['token', 'userInfo', 'loadingMore', 'isLoading', 'isBlock', 'update', 'baseURL'])
	},
	onLoad(query) {
		this.query = query
		uni.setNavigationBarColor({ backgroundColor: 'transparent', frontColor: this.navbarColor ? '#ffffff' : '#000000' })
		// #ifdef APP-PLUS
			this.UID = plus.device.uuid;
	   // #endif
	},
	methods: {
		...mapActions(['getUser', 'setUpdate', 'setState']),
		clearData() {
			this.List = []
			this.page = 0
			this.finish = false
		},
		ShowModal(modalName) {
			this.modalName = modalName
		},
		HideModal(e) {
			this.modalName = null
		},
		async copy(data, toast) {
			await uni.setClipboardData({ data })
			this.$uni.showToast({ title: this.$t('user').fzcg || toast, icon: 'none' })
			this.modalName && this.HideModal()
		},
		checkRule(formData, rule) {
			// console.log(formData)
			let checkRes = this.$checker.check(formData || this.form, rule || this.rule)
			if (!checkRes) {
				this.$uni.showToast({ title: this.$checker.error })
				return false
			}
			return true
		},
		pushPage(path, query = {}, mode = 'push') {
			console.log('page',path)
			if (!path) {
				this.$uni.showToast({ title: '正在开发,敬请期待' })
				return
			}
			uni.navigateTo({
				url:path
			})
		},
		navigatePage(path,type = 'fade-in', duration = 200) {
			if(!this.click){
				uni.navigateTo({
					url:path,
					animationType:type,
					animationDuration:duration,
					success: () => {
						this.click = false
						// #ifdef H5
						setTimeout(()=>{this.click = false},10)
						// #endif
						
					}
				})
			}
			this.click = true
		}
	}
})
